// JavaScript Document
function redirectUrl(url){
	window.location.href = url;
}
/*截取字符串…*/
function format(className,num1,n,num2,m){
	$("."+className).each(function() {
		$(this).find("p").each(function() {
			var str=$(this).html();
				title=$(this).siblings(".title");
			if(str.length>num1){
				var newTxt=str.substring(0,n)+"…";
				$(this).html(newTxt);
			}
			if(title.length!=0){
			if(title.html().length>num2){
				var newTxt=title.html().substring(0,m)+"…";
				title.html(newTxt);
			}
			}	
        });
    });	
}
function addMargin(obj){
	var oHei=-obj.outerHeight()/2+"px";
	var oWid=-obj.outerWidth()/2+"px";
	obj.css({"margin-top":oHei,"margin-left":oWid});
}//浏览器中居中
function closeParent(obj){
	obj.parent().parent().hide();
	if($(".shade3").is(":visible")){
		$(".shade3").hide();
	}else if($(".shade2").is(":visible")){
		$(".shade2").hide();
	}else{
		$(".shade1").hide();
	}
}//关闭按钮
function addLoadingBar(){
	if($(".loadingBar").children().length!=1){
		var loading=$("<div class='loadingBar' style='width:100%;height:31px;text-align:center;position:absolute;left:0;bottom:0;'><img src='../../images/loading.gif'></div>");
		$("body").append(loading);
	}
}
function detLoadingBar(){
	$(".loadingBar").remove();
}
window.preViewImg = (function(){
	var imgsSrc = {};
	function reviewImage(dsrc, gid) {
	    if (typeof window.WeixinJSBridge != 'undefined') {
	        WeixinJSBridge.invoke('imagePreview', {
	            'current' : dsrc,
	            'urls' : imgsSrc[gid]
	        });
	    }
	}
	function init(thi, evt){
		var dsrc = thi.getAttribute("data-src");
		var gid = thi.getAttribute("data-gid");

		if(dsrc && gid){
			imgsSrc[gid] = imgsSrc[gid]||[];
			imgsSrc[gid].push(dsrc);
			thi.addEventListener("click", function(){
				reviewImage(dsrc, gid);
			}, false);
		}
	}
	return init;
})();//预览图

function addLoading(){
	var loading=$("<div class='shadow'><div class='shadowBg'></div><div class='loading' style='z-index: 999'><img src='../../images/loading.gif' style='width:100px;'><br>正在上传数据..</div></div>");
	$("body").css("overflow-y","hidden");
	$("body").prepend(loading);	
}//loading图显示
function addLoadingImage(){
	var loading=$("<div class='shadow'><div class='shadowBg'></div><div class='loading' style='z-index: 999'><img  src='../../images/loading.gif' style='width:100px;'><br>上传图片可能较慢，请耐心等待！</div></div>");
	$("body").css("overflow-y","hidden");
	$("body").prepend(loading);	
}//loading图显示
function delLoading(){
	if($(".shadow").length!=0){
		$("body").css("overflow-y","scroll");
		$(".shadow").remove();	
	}	
}//loading图隐藏
function addRefresh2(){
	var Refresh=$("<div class='loadingTB'><img src='../../images/loadingYeah.gif'>正在加载……</div>");	
	$("body").append(Refresh);
}
function addRefresh(){
	var Refresh=$("<div class='loadingTB'><img src='images/loadingYeah.gif'>正在加载……</div>");	
	$("body").append(Refresh);
}//刷新提示显示
function delRefresh(){
	$(".loadingTB").remove();
}//刷新提示隐藏

function showTestDel(id){
	var delDiv=$("<div class='shade shade1' style='display:block;'></div>"
	+"<div class='hideDiv testDiv' style='display:block;'><div class='closeTop'><strong>温馨提示</strong><span onclick='closeParent($(this))' class='closeThe'><img src='../../images/close.png'></span></div>"
	+"<p>您确定要删除吗？</p>"
    +"<div class='BottomBtn'><input type='button' value='取消' onclick='removeTestDel()'  class='del'><input type='button' value='确认' onclick='removeTestDel();deleteInfo("+id+")' class='pay'></div></div>");
	$("body").append(delDiv);
	addMargin($(".hideDiv"));
}//显示是否确定删除提示框
function removeTestDel(){
	$(".testDiv").prev(".shade").remove();
	$(".testDiv").remove();
}//移除删除提示框
